<?php
include("page.class.php");
$img=getImageInfo($_POST['id']);
$finished = ($img[0]->finished == 0) ? '未解决' : '已解决';
echo "<h1 class='in_content_imgname mt15 ml20 '>".$img[0]->name."</h1>";
echo "<p class='in_content_imginfo'>拍摄者：".showUserName($img[0]->post_user)."</p>";
echo "<p class='fl ml20 222 f14'>地址：<div class='in_content_ico fl'></div><p class='in_content_addr'>".$img[0]->address."</p></p>";
echo "<p class='in_content_imginfo'>描述：".$img[0]->remark."</p>";
echo "<p class='in_content_imginfo'>关心(".$img[0]->concern.")&nbsp;&nbsp;&nbsp;".$finished."</p>";
if($img[0]->finished == 0){echo "<div class='label icon_1'></div>";}
else{ echo "<div class='label icon_2'></div>";}
for($i=0;$i < count($img);$i++){
	if($img[$i]->img_id){
		echo '<div class="in_content_imginfo">更新时间：'.$img[$i]->create_time.'</div>';
		echo '<div class="ml20 mb20"><img style="width:300px" onload="original(this);" src="image.php?up_id='.$img[$i]->id.'&type=media"  alt="照片名" /></div>';
	}
	else {
		echo '<div class="in_content_imginfo">更新时间：'.$img[$i]->create_time.'</div>';
		echo '<div class="ml20 mb20"><img style="width:300px" onload="original(this);" src="image.php?id='.$img[$i]->id.'&type=media"  alt="照片名" /></div>';
	}
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="css/style.css">
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript">
	function checkComm(){	
		if($("#comment").val()==''){
			//alert("a");
			$("#check_comm").text("请输入评论内容");
			return false;
			}else{
				$.ajax({url:"page.class.php?request=1&id="+$(".img_id_frame").val()+"&comment="+$("#comment").val()+"",dataType : 'json',async:false,success:function(result){
					var html="<div class='co none' style='width:350px'><div class=''>"+$("#user_avatar").html()+"</div><div class=''>"+$("#user_name").html()+"<span class='7e7e7e'>&nbsp &nbsp "+result[0].time+"<span></div><div class=''><span class='7e7e7e'>"+$("#comment").val()+"</span></div></div>";
					$(".co").eq(0).after(html);
					$(".co").eq(1).show(300);
					$("#comment").val("");				
					}});
				}
				return false;	
		}		
		function showmore(){
			if($("#showmore").text()=="查看更多"){
				$("#hidden_comm").show(300);
				$("#showmore").text("收起");
			}else{
				$("#hidden_comm").hide(300);
				$("#showmore").text("查看更多");
				}
			return false;
			}

	</script>


<!--图片更新-->
<div class="update">
	<form action="upload_update.php" method="POST" enctype="multipart/form-data" target="hidden_frame">
		<p class="in_content_imginfo">提交你的更新：</p>
		<input type="file" name="up_image" class="post_in fl dib" style="width:400px;margin-left:20px;"><input type="hidden" name="this_id" class="this_id" value="<?php echo $_POST['id'];?>">
		<div class="post_de fl"><p class="in_content_imginfo">描述：</p><textarea name="remark" class="description  fl ml20" style="margin-bottom:0;width:400px"></textarea></div>
		<iframe name="hidden_frame" id="hidden_frame" style="border:none;display:none"></iframe>
		<?php if($_SESSION['login_mail'] == $img[0]->post_user && $img[0]->finished == 0)
		echo '<div style="float:left;padding:5px 60px 5px 0;font-size:14px;color:#222;" class="ml20"><input type="checkbox" name="finished" value="1">&nbsp;&nbsp;问题已解决</div>';
		?>
		<input type="submit" name="up_submit" value="提&nbsp交&nbsp更&nbsp新" class="post_button dib" style="float:right;margin-right:30px;" onclick="">
	</form>
</div>

<!--评论部分-->
<div class="comment" style="width:420px;padding:20px;">
	<div class="co in" style="margin:0 -20px;padding:0 20px;width:420px;border-bottom:1px solid #fff;">
		<form method="POST" name="comm_form">
			<input type="hidden" class="img_id_frame" value="<?php echo $_POST['id'];?>">
			<div class="owner_img" style="margin:0 20px 0 0;padding-bottom:30px;"><img src="<?php if($_SESSION['login_mail']==""){echo "img/simple.png";}else{echo showUserAvatar($_SESSION['login_mail']);}?>"  style="width:50px;height:50px" alt="" /></div>
			<div class="co_input w200">
				<?php if($_SESSION['login_mail']!=""){?>
					<textarea name="comment" id="comment" class="co_in" style="width:330px"></textarea>
				<?php }else{?>
				<p class="in_content_imginfo" style="width:300px;margin-left:-20px;">游客回复请先<a class="login_in" href="#" onclick='showLogin()'>登录</a></p>
				<?php }?>
			</div>
			<div class="co_button" style="width:300px;margin:15px 0 20px 0;"><a href="#" class="comment_button dib" onclick="return checkComm();"><span>评&nbsp&nbsp论</span></a></div>
			<div id="check_comm" style="width:200px;height:20px"></div>
		</form>
	</div>
	<!--新评论时的用户数据--->
	<div id="co_hidden" style="display:none">
		<div id="user_avatar"><img style='width:40px; height:40px;' src="<?php echo showUserAvatar($_SESSION['login_mail']);?>" alt="" /></div>
		<div id="user_name"><a href="" class="f16  545454"><?php echo showUserName($_SESSION['login_mail']);?></a></div>
	</div>
<?php
$sql="select * from comment where img_id='$_POST[id]' order by create_time desc limit 5";
$re=mysql_query($sql)or die(mysql_error());
$i=1;
while($row=mysql_fetch_array($re)){
	if($i==5){echo "<div id='hidden_comm' style='display:none'>";}
	echo "<div class='co' style='margin:0 -20px 0 -20px;width:420px;padding:20px;border-top:1px solid #eee;border-bottom:1px solid #fff;'>";
	echo "<div class='fl'><img style='width:40px; height:40px;' src='".showUserAvatar($row['comm_user'])."' /></div>";
	echo "<div class='fl' style='margin-left:10px'><a href='user_album.php?user=".$row['comm_user']."' class='f16  545454 vis' target='_blank'>".showUserName($row['comm_user'])."</a><span class='7e7e7e f12'> &nbsp 于&nbsp".$row['create_time']."<span></div>";
	echo "<div class='fl' style='width:300px;margin-left:10px'><span class='7e7e7e f14'>".$row['comment']."</span></div>";
	echo "</div>";
	$i++;
	}
	echo "</div>";
?>